package com.heima.search.web;

import com.hmall.common.dto.Item;
import com.hmall.common.result.PageResult;
import com.hmall.common.result.Result;
import com.hmall.feign.clients.ItemFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
@RequestMapping("/searchItem")
public class ItemController {
    @Autowired
    private ItemFeignClient itemFeignClient;


    @GetMapping("/itemAll")
    public Result listResult() {
        Result<List<Item>> all = itemFeignClient.all();
        return Result.success(all);
    }

    /**
     * 测试itemfeign的page接口
     */
    @GetMapping("/feignPage")
    public PageResult<Item> page() {
//        PageItem pageItem = new PageItem();
//        pageItem.setSize(5);
//        pageItem.setPage(1);
        return itemFeignClient.pageES(1, 5);

    }
}
